"""
Basic Classes...
$Id: basic_drawables.py,v 1.2 2004/01/23 09:57:35 krawczyk Exp $
"""

class Drawable:
    """
    Everything which is drawable and has an Update function.
    Update -- called once a frame to update status of Drawable
    Draw -- Draw stuff and return dirty rectangles
    Erase -- erase all dirty rectangles and return list of regions to update
    """

    def __init__(self):
        pass
    
    def Update(self):
        """Update stuff"""
        raise NotImplementedError

    def Draw(self, on_Surface):
        "Should return a list of dirty rectangles"
        raise NotImplementedError

    def Erase(self, on_Surface, with_Bg):
        "Should return a list of dirty rectangles"
        raise NotImplementedError


class Drawable_erase(Drawable):
    """
    Hier a erase function is already implemented.
    dirtyrect -- list of dirty rectangles
    """

    def __init__(self):
        self.dirtyrect = []

    def Erase(self, on_Surface, with_Bg):
        "Erases all dirtyrect rectangles"
        r = []
        for i in self.dirtyrect:
            r.append( on_Surface.blit(with_Bg, i, i) )
        self.dirtyrect = []
        return r

class Drawable_gamedata(Drawable):
    """A drawable which keeps a pointer to a gamedata structure"""
    def __init__(self, gamedata):
        self.gamedata = gamedata

class Drawable_stat(Drawable):
    """A drawable with a status.
    status -- Current status. 0 == Nothing of interest or default
    """
    status = 0

    def Status(self):
        return self.status
